#include <msp430.h>
#include "main.h"

void sampleChannel(unsigned int *ret,int channel)
{
	ADC10CTL0 &= ~(ENC + ADC10SC); //Stop any conversion
	ADC10CTL1 = channel;
	ADC10CTL0 |= ENC + ADC10SC; //Start conversion
	__bis_SR_register(LPM0_bits + GIE);//wait for result.
	ADC10CTL0 &= ~(REFON);
	*ret = ADC10MEM; //Disable sensor, it seems to have been unplugged!
}

/*ADC10 Interrupt*/
/*Analog to Digital Converter Interrupt Handler*/
#ifdef __GNUC__
__attribute__((interrupt(ADC10_VECTOR)))
#else
#pragma vector = ADC10_VECTOR
__interrupt
 #endif
void ADC10_ISR(void)
{
	__bic_SR_register_on_exit(LPM0_bits + GIE); //Exit LPM0
}
